/*
 * @Author: cmd 
 * @wechat: cmd_develop 
 * @Date: 2019-04-23 17:27:50 
 * @Last Modified by: cmd
 * @Last Modified time: 2019-04-25 19:45:09
 * @Description: 
 */

import orc from "../orc";
const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {
    @property(cc.Node)
    money_node:cc.Node = null;
   
    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        console.log('game_ui memory_data.user_data:',orc.memory_data.user_data);
        //事件注册
        orc.event_manager.add_listener('money_display',this.money_display.bind(this));
    }

    money_display(money:number){ 
        this.money_node.getChildByName('money_label').getComponent(cc.Label).string = String(money);
        this.money_node.getChildByName('money_plus').active = false;
    }

    start () {
        console.log('game_ui memory_data.user_data:',orc.memory_data.user_data);
        console.log('game_ui memory_data.user_data:',orc.memory_data.user_data.money);
        orc.event_manager.dispatch_event('money_display',100);
    }

    async on_test_click() {
        console.log("on_test_click");
        let body ={};
       

        //获取用户信息
        let res_login:any = await orc.net_http.http_post(orc.url_config.empty_test,body);       //验证微信信息
        
        if(res_login == 'error')
        {
            console.error('net_http get_openid() error');
            return;
        } 
        console.log('res_login:',res_login);
	}

    // update (dt) {}
}
